package cn.semcorp.zhuhaizj.controller;

import cn.semcorp.zhuhaizj.common.Common;
import cn.semcorp.zhuhaizj.pojo.dto.*;
import cn.semcorp.zhuhaizj.restful.JsonResult;
import cn.semcorp.zhuhaizj.services.impl.TrainingServiceImpl;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/training")
@Api(tags ="培训")
public class TrainingController {
    @Autowired
    private TrainingServiceImpl trainingService;

    /**
     * 删除晋升记录
     */
    @PostMapping("/delete/promotion/{id}")
    public JsonResult deletePromotionById(@PathVariable String id){
        trainingService.deletePromotionById(id);
        return JsonResult.ok("删除成功!");
    }

    /**
     * 导入培训记录
     * @param list
     * @return
     */
    @PostMapping("/insert/record")
    public JsonResult insertRecordList(@RequestBody List<InsertRecordDTO> list) {
        trainingService.addRecords(list);
        return JsonResult.ok("成功导入"+list.size()+"条数据");
    }

    /**
     * 导入年度教育培训计划
     *
     * @param list
     * @return
     */
    @PostMapping("/inputEducationPlan")
    public JsonResult inputEducationPlan(@RequestBody List<TrainingInputEducationDTO> list) {
        int rows = trainingService.inputEducationPlan(list);
        if (rows != list.size()) {
            return JsonResult.failed("导入年度教育培训计划失败!");
        }
        return JsonResult.ok("导入年度教育培训计划成功!");
    }

    /**
     * 导入年度技能认定计划
     *
     * @param list
     * @return
     */
    @PostMapping("/inputSkillPlan")
    public JsonResult inputSkillPlan(@RequestBody List<TrainingInputSkillDTO> list) {
        int rows = trainingService.inputSkillPlan(list);
        if (rows != list.size()) {
            return JsonResult.failed("导入年度技能认定计划失败!");
        }
        return JsonResult.ok("导入年度技能认定计划成功!");
    }

    /**
     * 查询年度教育计划
     */
    @GetMapping("/loadEducationList")
    public JsonResult selectEducationList() {
        return JsonResult.ok(trainingService.selectEducationList());
    }

    /**
     * 查询年度技能培训计划
     */
    @GetMapping("/loadSkillList")
    public JsonResult selectSkillList() {
        return JsonResult.ok(trainingService.selectSkillList());
    }

    /**
     * 查询新增的课程的编号延续
     */
    @GetMapping("/select/auto/{model}")
    public JsonResult selectAutoCodeByModel(@PathVariable String model) {
        return JsonResult.ok(trainingService.selectAutoCodeByModel(model));
    }

    /**
     * 初始化查询课程列表
     */
    @GetMapping("/select/course/list")
    public JsonResult selectTrainingClassList() {
        return JsonResult.ok(trainingService.selectTrainingClassList());
    }


    /**
     * 查询课程列表
     */
    @GetMapping("/query/subject/list")
    public JsonResult querySubjectList(QuerySubjectDTO dto) {
        return JsonResult.ok(trainingService.querySubjectList(dto));
    }

    /**
     * 修改课程
     */
    @PostMapping("/updateTraining")
    public JsonResult updateTraining(TrainingDataDTO trainingDataDTO) {
        trainingService.updateTraining(trainingDataDTO);
        return JsonResult.ok("修改成功!");
    }


    /**
     * 删除课程
     */
    @PostMapping("/deleteTraining/{id}")
    public JsonResult deleteTrainingById(@PathVariable String id) {
        trainingService.deleteTrainingById(id);
        return JsonResult.ok("删除成功!");
    }


    /**
     * 新增
     */
    @PostMapping("/add")
    public JsonResult add(TrainingDataDTO trainingDataDTO) {
        trainingService.add(trainingDataDTO);
        return JsonResult.ok("新增成功");
    }


    /**
     * 教育计划点击选择完成人提交
     */
    @PostMapping("/educationPersonUp/{id}")
    public JsonResult educationPersonUp(@PathVariable String id,@RequestBody List<String> list){
        trainingService.selectPersonEducationUpById(id,list);
        return JsonResult.ok("提交成功,数据同步完成!");
    }


    /**
     * 技能认定点击选择完成人提交
     */
    @PostMapping("/skillPersonUp/{id}")
    public JsonResult skillPersonUp(@PathVariable String id,@RequestBody List<String> list){
        trainingService.selectPersonSkillUpById(id,list);
        return JsonResult.ok("提交成功,数据同步完成!");
    }



    /**
     * 初始化加载花名册
     */
    @GetMapping("/selectFlowerList")
    public JsonResult selectFlowerList() {
        return JsonResult.ok(trainingService.selectFlowerList());
    }

    /**
     * 初始化加载花名册 二次方法
     */
    @GetMapping("/select/flower/list/condition")
    public JsonResult selectFlowerListCondition() {
//        return JsonResult.ok(trainingService.selectFlowerListCondition());
        return JsonResult.ok(trainingService.selectFlowerList());
    }


    /**
     * 初始化加载花名册-特殊
     */
    @GetMapping("/select/flower/list/other")
    public JsonResult selectFlowerListOther() {
        return JsonResult.ok(trainingService.selectFlowerListOther());
    }
    /**
     * 根据id查询人员信息
     */
    @GetMapping("/select/flowers/{id}")
    public JsonResult selectFlowersById(@PathVariable String id){
        return JsonResult.ok(trainingService.selectFlowerById(id));
    }

    /**
     * 根据id查询人员信息
     */
    @GetMapping("/selectFlower/{id}")
    public JsonResult selectFlowerById(@PathVariable String id) {
        return JsonResult.ok(trainingService.selectFlowerById(id));
    }

    /**
     * 初始化查询考试计划列表
     */
    @GetMapping("/select/test/list")
    public JsonResult selectTestList() {
        return JsonResult.ok(trainingService.selectTestList());
    }

    /**
     * 查询考试计划列表
     */
    @GetMapping("/query/test/list")
    public JsonResult queryTestList(QueryTestDTO dto) {
        return JsonResult.ok(trainingService.queryTestList(dto));
    }


    /**
     * 初始化查询培训计划列表
     */
    @GetMapping("/select/study/list")
    public JsonResult selectTrainingList() {
        return JsonResult.ok(trainingService.selectTrainingList());
    }


    /**
     * 查询培训计划列表
     */
    @GetMapping("/query/study/list")
    public JsonResult queryStudyList(QueryStudyDTO dto) {
        return JsonResult.ok(trainingService.queryStudyList(dto));
    }

    /**
     * 查询考核记录
     */
    @GetMapping("/query/performance/list")
    public JsonResult queryPerformanceList(QueryPerformanceDTO dto) {
        return JsonResult.ok(trainingService.queryPerformanceList(dto));
    }

    /**
     * 查询学习整个情况
     */
    @GetMapping("/select/information")
    public JsonResult selectInformation(){
        return JsonResult.ok(trainingService.selectInformation());
    }

    /**
     * 查询车间学习整个能力分布情况
     */
    @GetMapping("/select/AbleByWorkshop")
    public JsonResult selectAbleByWorkshop(){
        return JsonResult.ok(trainingService.selectAbleByWorkshop());
    }

    /**
     * 查询车间学习次数情况
     */
    @GetMapping("/select/passByWorkshopCount")
    public JsonResult selectPassByWorkshopCount(){
        return JsonResult.ok(trainingService.selectPassByWorkshopCount());
    }

    /**
     * 查询车间学习合格率情况
     */
    @GetMapping("/select/passByWorkshopPass")
    public JsonResult selectPassByWorkshopPass(){
        return JsonResult.ok(trainingService.selectPassByWorkshopPass());
    }

    /**
     * 查询整体的合格率
     * @return
     */
    @GetMapping("/select/informationEchartsPercent")
    public JsonResult selectInformationEchartsPercent(){
        return JsonResult.ok(trainingService.selectInformationEchartsPercent());
    }

    /**
     * 查询所有的等待结果的学习计划
     * @return
     */
    @GetMapping("/select/studyListCount")
    public JsonResult selectStudyListCount(){
        return JsonResult.ok(trainingService.selectStudyListCount());
    }

    /**
     * 查询整体的能力分布
     * @return
     */
    @GetMapping("/select/LeidaAble")
    public JsonResult selectLeidaAble(){
        return JsonResult.ok(trainingService.selectLeidaAble());
    }

    /**
     * 查询整体的次数
     * @return
     */
    @GetMapping("/select/informationEchartsCount")
    public JsonResult selectInformationEchartsCount(){
        return JsonResult.ok(trainingService.selectInformationEchartsCount());
    }

    /**
     * 查询类型
     * @return
     */
    @GetMapping("/select/ClassList")
    public JsonResult selectClassList(){
        return JsonResult.ok(trainingService.selectClassList());
    }

//    /**
//     * 根据id删除课表
//     */
//    @GetMapping("/delete/{id}")
//    public JsonResult<String> deleteById(@PathVariable String id){
//        trainingService.deleteById(id);
//        return JsonResult.ok("删除成功!");
//    }


    /**
     * 模糊查询
     * @param content
     * @return
     */
    @GetMapping("/selectMH")
    public JsonResult selectMH(String content) {
        return JsonResult.ok(trainingService.selectMH(content));
    }


    @PostMapping("/updatePeople")
    public JsonResult<String> updatePeopleById(UpdatePeopleDTO dto) {
        trainingService.updatePeopleById(dto);
        return JsonResult.ok("修改成功!");
    }

    /**
     * 根据id查询人员信息
     */
    @GetMapping("/selectFlowerUser/{id}")
    public JsonResult selectFlowerUserById(@PathVariable String id) {
        return JsonResult.ok(trainingService.selectFlowerUserById(id));
    }

    /**
     * 根据id查询新人育成计划
     */
    @GetMapping("/select/new/plan/{id}")
    public JsonResult selectNewPlanById(@PathVariable String id) {
        return JsonResult.ok(trainingService.selectNewPlan(id));
    }

    /**
     * 能力打造 - 提交计划
     */
    @PostMapping("/submit/insert/person/plan/{id}")
    public JsonResult submitInsertPersonPlan(@PathVariable String id,@RequestBody List<SubmitPersonPlanDTO> list) {
        trainingService.submitInsertPersonPlan(list,id);
        return JsonResult.ok("提交成功,请回表中查询进度!");
    }

    /**
     * 能力打造 - 提交计划
     */
    @PostMapping("/submit/delete/person/plan/{id}")
    public JsonResult submitDeletePersonPlan(@PathVariable String id) {
        trainingService.submitDeletePersonPlan(id);
        return JsonResult.ok("删除成功!");
    }

    /**
     * 能力打造 - 根据id完成计划
     */
    @PostMapping("/submit/update/person/plan/{id}")
    public JsonResult submitUpdatePersonPlan(@PathVariable String id) {
        trainingService.submitUpdatePersonPlan(id);
        return JsonResult.ok("提交成功,请回表中查询进度!");
    }

    /**
     * 能力打造 - 根据id查询计划
     */
    @GetMapping("/select/personal/plan/{id}")
    public JsonResult selectPersonalPlanById(@PathVariable String id) {
        return JsonResult.ok(trainingService.selectPersonalPlanById(id));
    }

    /**
     * 更新新人育成完成状态
     */
    @PostMapping("/update/new/person/plan/over/{id}")
    public JsonResult updateNewPersonPlanOverById(@PathVariable String id) {
        trainingService.updateNewPersonPlanOverById(id);
        return JsonResult.ok("计划更新成功!");
    }

    /**
     * 查询考试记录列表
     * @return
     */
    @GetMapping("/select/test/record/list")
    public JsonResult selectTestRecordList(
            @RequestParam(required = false, defaultValue = Common.DEFAULT_PAGE) Integer page,
            @RequestParam(required = false, defaultValue = Common.DEFAULT_PAGE_SIZE) Integer pageSize
    ) {
        //<JsonPage<RecordDTO>>
        return JsonResult.ok(trainingService.selectTestRecordList(page, pageSize));
    }

    /**
     * 查询培训记录列表
     * @return
     */
    @GetMapping("/select/training/record/list")
    public JsonResult selectTrainingRecordList(
            @RequestParam(required = false, defaultValue = Common.DEFAULT_PAGE) Integer page,
            @RequestParam(required = false, defaultValue = Common.DEFAULT_PAGE_SIZE) Integer pageSize
    ) {
        //<JsonPage<RecordDTO>>
        return JsonResult.ok(trainingService.selectTrainingRecordList(page, pageSize));
    }

    /**
     * 根据姓名查询奖惩记录统计 分数
     */
    @GetMapping("/select/count/assess/all/{name}")
    public JsonResult selectCountAssessAllByName(@PathVariable String name){
        return JsonResult.ok(trainingService.selectCountAssessAllByName(name));
    }

    /**
     * 根据车间查询奖惩记录统计 分数
     */
    @GetMapping("/select/count/assess/workshop")
    public JsonResult selectCountAssessAllWorkshop(){
        return JsonResult.ok(trainingService.selectCountAssessAllWorkshop());
    }

    /**
     * 查询整个部门查询奖惩记录统计 分数
     */
    @GetMapping("/select/count/assess/workshop/all")
    public JsonResult selectCountAssessAllWorkshopAll(){
        return JsonResult.ok(trainingService.selectCountAssessAllByWorkshopAll());
    }

    /**
     * 查询所有的考核记录违反类型
     */
    @GetMapping("/selectViolateList")
    public JsonResult selectViolateList(){
        return JsonResult.ok(trainingService.selectViolateList());
    }

    /**
     * 根据姓名查询所有考试记录
     * @return
     */
    @GetMapping("/select/test/record/by/condition")
    public JsonResult selectTestRecordByCondition(SelectTestRecordByNameDTO dto) {
        return JsonResult.ok(trainingService.selectTestRecordByCondition(dto));
    }

    /**
     * 根据姓名查询所有培训记录
     * @return
     */
    @GetMapping("/select/training/record/by/condition")
    public JsonResult selectTrainingRecordByCondition(SelectTrainingRecordByNameDTO dto) {
        return JsonResult.ok(trainingService.selectTrainingRecordByCondition(dto));
    }


    /**
     * 生成当月待完成培技能认定
     *
     * @return
     */
    @PostMapping("/skill/plan/check")
    public JsonResult skillPlanCheck() {
        return JsonResult.ok(trainingService.skillPlanCheck());
    }

    /**
     * 生成当月待完成教育计划
     *
     * @return
     */
    @PostMapping("/education/plan/check")
    public JsonResult educationPlanCheck() {
        return JsonResult.ok(trainingService.educationPlanCheck());
    }

    /**
     * 查询教育培训月计划
     * @return
     */
    @GetMapping("/selectEducationPlanList")
    public JsonResult selectEducationPlanList() {
        return JsonResult.ok(trainingService.selectEducationPlanList());
    }

    /**
     * 查询技能认定月计划
     *
     * @return
     */
    @GetMapping("/selectSkillPlanList")
    public JsonResult selectSkillPlanList() {
        return JsonResult.ok(trainingService.selectSkillPlanList());
    }

    @PostMapping("/updateEducation")
    public JsonResult updateEducationPlanStateById(IdDTO id) throws Throwable {
        trainingService.updateEducationPlanStateById(id.getId());
        return JsonResult.ok("此教育培训月计划记录已完成,年度计划表同步更新完成!");
    }

    @PostMapping("/updateSkill")
    public JsonResult updateSkillPlanStateById(IdDTO id) throws Throwable {
        trainingService.updateSkillPlanStateById(id.getId());
        return JsonResult.ok("此技能认定月计划记录已完成,年度计划表同步更新完成!");
    }


    /**
     * 查询待完成培训计划临时
     * @param
     * @return
     */
    @GetMapping("/countStudy")
    public JsonResult countStudy() {
        return JsonResult.ok(trainingService.countStudy());
    }

    /**
     * 待完成事项统计
     * 教育培训
     */
    @GetMapping("/countEducationPlan")
    public JsonResult countEducationPlanByMonth() {
        int row = trainingService.countEducationPlanByMonth();
        if (row == 0){
            return JsonResult.failed("");
        }
        return JsonResult.ok(row);
    }

    /**
     * 技能认定统计
     */
    @GetMapping("/countSkillPlan")
    public JsonResult countSkillPlanByMonth() {
        int row = trainingService.countSkillPlanByMonth();
        if (row == 0){
            return JsonResult.failed("");
        }
        return JsonResult.ok(row);
    }


    /**
     * 结果上传 - 教育
     */
    @PostMapping("/uploadEducation/{content}")
    public JsonResult insertEducationPicture(@PathVariable String content, @RequestBody MultipartFile file) throws IOException {
        String[] strings = content.split("&", -1);
        String outId = strings[0];
        String date = strings[1];
        String base64 = Base64.encodeBase64String(file.getBytes());
        trainingService.insertEducationPicture(outId, date, base64);
        return JsonResult.ok("上传成功!");
    }

    /**
     * 结果上传 - 技能
     */
    @PostMapping("/uploadSkill/{content}")
    public JsonResult<String> insertSkillPicture(@PathVariable String content, @RequestBody MultipartFile file) throws IOException {
        String[] strings = content.split("&", -1);
        String outId = strings[0];
        String date = strings[1];
        String base64 = Base64.encodeBase64String(file.getBytes());
        trainingService.insertSkillPicture(outId, date, base64);
        return JsonResult.ok("上传成功!");
    }

    /**
     * 查看照片 - 教育
     */
    @GetMapping("/queryEducationPictureById/{id}")
    public JsonResult queryRecordPictureById(@PathVariable String id) {
        return JsonResult.ok(trainingService.queryEducationPictureById(id));
    }

    /**
     * 查看照片 - 技能
     */
    @GetMapping("/querySkillPictureById/{id}")
    public JsonResult querySkillPictureById(@PathVariable String id) {
        return JsonResult.ok(trainingService.querySkillPictureById(id));
    }

    /**
     * 计划待完成
     * 是否上传结果
     */
    @GetMapping("/querySkillPictureCount/{id}")
    public JsonResult querySkillPictureCountById(@PathVariable String id) {
        return JsonResult.ok(trainingService.querySkillPictureCountById(id));
    }

    @GetMapping("/queryEducationPictureCount/{id}")
    public JsonResult queryEducationPictureCountById(@PathVariable String id) {
        return JsonResult.ok(trainingService.queryEducationPictureCountById(id));
    }

    /**
     * 批量创建的培训任务, 生成多条记录
     */
    @PostMapping("/batchTrainingInsert")
    public JsonResult batchTrainingInsert(BatchTrainingDTO dto) {
            trainingService.batchTrainingInsert(dto);
            return JsonResult.ok("批量培训任务执行成功!");
    }

    /**
     * 查询所有的课程代码列表
     */
    @GetMapping("/selectCodeList")
    public JsonResult selectCodeList() {
            return JsonResult.ok(trainingService.selectCodeList());
    }

    /**
     * 查询所有的课程类别
     */
    @GetMapping("/selectClassModelList")
    public JsonResult selectClassModelList() {
        return JsonResult.ok(trainingService.selectClassModelList());
    }

    /**
     * 查询所有的培训时段
     */
    @GetMapping("/selectTrainingDateList")
    public JsonResult selectTrainingDate(){
            return JsonResult.ok(trainingService.selectTrainingDate());
    }

    /**
     * 查询所有的教育类型
     */
    @GetMapping("/selectEducationModelList")
    public JsonResult selectEducationModel(){
            return JsonResult.ok(trainingService.selectEducationModel());
    }

    /**
     * 查询所有的培训类型
     */
    @GetMapping("/selectTrainingModelList")
    public JsonResult selectTrainingModel(){
            return JsonResult.ok(trainingService.selectTrainingModel());
    }

    /**
     * 查询所有的课程类型
     */
    @GetMapping("/selectClassModel")
    public JsonResult selectClassModel(){
            return JsonResult.ok(trainingService.selectClassModel());
    }

    /**
     * 查询制浆车间总人数
     */
    @GetMapping("/countPeople/information")
    public JsonResult countPeople(){
            return JsonResult.ok(trainingService.countPeople());
    }

    /**
     * 根据课程类别查询对应的课程代码
     */
    @GetMapping("/selectClassCode/{classModel}")
    public JsonResult selectClassCodeByClassModel(@PathVariable String classModel) {
            return JsonResult.ok(trainingService.selectClassCodeByClassModel(classModel));
    }


    /**
     * 根据课程代码查询对应的课程内容和课程代码
     */
    @GetMapping("/selectTopicContent/{classCode}")
    public JsonResult selectTopicContentByClassCode(@PathVariable String classCode) {
            return JsonResult.ok(trainingService.selectTopicContentByClassCode(classCode));
    }


    /**
     * 添加考试任务
     */
    @PostMapping("/addTestPlan")
    public JsonResult addTestPlan(@RequestBody List<StudyDTO> list) {
            trainingService.addTestPlan(list);
            return JsonResult.ok("提交成功,请回考试计划中查看进度吧!");
    }

    /**
     * 添加培训任务
     */
    @PostMapping("/addStudyPlan")
    public JsonResult addStudyPlan(@RequestBody List<StudyDTO> list) {
        trainingService.addStudyPlan(list);
        return JsonResult.ok("提交成功,请回培训计划中查看进度吧!");
    }

    /**
     * 添加人员
     */
    @PostMapping("/addPeople")
    public JsonResult addPeople(AddPeopleDTO addPeople) {
            trainingService.addPeople(addPeople);
            return JsonResult.ok("添加成功!");
    }


    /**
     * 删除员工
     */
    @PostMapping("/delete/people/all/information/{id}")
    public JsonResult<String> deletePeople(@PathVariable String id) {
            trainingService.deletePeopleById(id);
            return JsonResult.ok("删除成功!");
    }


    /**
     * 上传学习计划的照片
     */
    @PostMapping("/uploadStudyPlan/{id}")
    public JsonResult uploadStudyPlan(@RequestBody MultipartFile file, @PathVariable String id) throws IOException {
            String base64 = Base64.encodeBase64String(file.getBytes());
            trainingService.uploadStudyPlanById(id, base64);
            return JsonResult.ok("上传成功!");
    }


    /**
     * 删除上传学习计划的照片
     */
    @PostMapping("/deleteStudyPlan/{id}")
    public JsonResult deleteStudyPlan(@PathVariable String id) {
            trainingService.deleteStudyPlanById(id);
            return JsonResult.ok("上传成功!");
    }
    /**
     * 根据id查询学习计划的照片
     */
    @GetMapping("/queryStudyPictureById/{id}")
    public JsonResult queryStudyPictureById(@PathVariable String id) {
            return JsonResult.ok(trainingService.queryStudyPictureById(id));
    }

    /**
     * 查询默认晋升的岗位和岗位类别
     */
    @GetMapping("/select/null/promotion/up/{post}")
    public JsonResult selectNullPromotionUpByPost(@PathVariable String post){
            return JsonResult.ok(trainingService.selectNullPromotionUpByPost(post));
    }

    /**
     * 根据查询学习计划是否上传过结果
     */
    @GetMapping("/queryStudyPictureCount/{id}")
    public JsonResult queryStudyPictureCountById(@PathVariable String id) {
            String[] strings = id.split(",",-1);
            if (strings.length == 1){
                int row = trainingService.queryStudyPictureCountById(id);
                if (row == 0){
                    return JsonResult.failed("无法审核,没有执行结果的记录,请上传后在操作!");
                }
                return JsonResult.ok("正常审核");
            }
            for (String string : strings) {
                int row = trainingService.queryStudyPictureCountById(string);
                if (row == 0){
                    return JsonResult.failed("无法批量审核,存在没有执行结果的记录,请上传后在操作!");
                }
            }
            return JsonResult.ok("正常审核");
    }

    /**
     * 根据id修改考试计划的状态
     */
    @PostMapping("/update/test/plan")
    public JsonResult updateTestById(@RequestBody List<StudyUpdateDTO> list) {
        trainingService.updateTestById(list);
        return JsonResult.ok("批量审核已完成!");
    }

    /**
     * 根据id修改培训计划的状态
     */
    @PostMapping("/update/training/plan")
    public JsonResult updateTrainingById(@RequestBody List<StudyDTO> list) {
        trainingService.updateTrainingById(list);
        return JsonResult.ok("批量审核已完成!");
    }

    /**
     * 作废
     * 批量添加学习计划的上传照片
     */
    @PostMapping("/updateStudyList")
    public JsonResult updateStudyListByIdList(List<IdDTO> id) {
            trainingService.updateStudyListByIdList(id);
            return JsonResult.ok("计划已完成!");
    }

    /**
     * 根据id删除学习计划
     */
    @PostMapping("/delete/study/{id}")
    public JsonResult deleteStudyById(@PathVariable Integer id) {
        trainingService.deleteStudyById(id);
        return JsonResult.ok("删除成功!");
    }

    /**
     * 根据id删除考试计划
     */
    @PostMapping("/delete/test/{id}")
    public JsonResult deleteTestById(@PathVariable Integer id) {
        trainingService.deleteTestById(id);
        return JsonResult.ok("删除成功!");
    }


    /**
     * 根据id查询员工的能力矩阵图
     */
    @GetMapping("/selectAblePicture/{name}")
    public JsonResult selectAblePictureByName(@PathVariable String name){
        return JsonResult.ok(trainingService.selectAblePictureByName(name));
    }


    /**
     * 根据姓名查询员工所有培训结果统计
     */
    @GetMapping("/selectPassPicture/{name}")
    public JsonResult selectPassPictureByName(@PathVariable String name){
        return JsonResult.ok(trainingService.selectPassPictureByName(name));
    }

    /**
     * 根据姓名查询员工的课程完成进度
     */
    @GetMapping("/selectProgressPicture/{name}")
    public JsonResult selectProgressPictureById(@PathVariable String name){
        return JsonResult.ok(trainingService.selectProgressPictureById(name));
    }

    /**
     * 创建晋升计划
     */
    @PostMapping("/addPromotionPlan")
    public JsonResult addPromotionPlan(@RequestBody ArrayList<AddPromotionDTO> list){
            trainingService.addPromotionPlan(list);
            return JsonResult.ok("提交成功,请回提名计划中查看进度吧!");
    }

    /**
     * 查询所有的晋升计划, 最近一次
     */
    @GetMapping("/selectPromotionList")
    public JsonResult selectPromotionList(){
        return JsonResult.ok(trainingService.selectPromotionList());
    }

    /**
     * 查询所有的晋升计划统计, 最近一次
     */
    @GetMapping("/countAuditPlan")
    public JsonResult countAuditPlan(){
        String row = trainingService.countAuditPlan();
        if (row == null || row.equals("0")){
            return JsonResult.failed("");
        }
        return JsonResult.ok(row);
    }

    /**
     * 根据id修改晋升计划中的考核结果(通过)
     */
    @PostMapping("/updateSuccessPromotion/{id}")
    public JsonResult updatePromotionStateSuccessById(@PathVariable String id){
        trainingService.updatePromotionStateSuccessById(id);
        return JsonResult.ok("操作成功,人员信息同步更新成功!");
    }

    /**
     * 查询所有的岗位类别
     */
    @GetMapping("/select/post/class/all")
    public JsonResult selectPostClassAll(){
        return JsonResult.ok(trainingService.selectPostClassALl());
    }

    /**
     * 根据选择的岗位类别查询岗位
     */
    @GetMapping("/select/post/{postClass}")
    public JsonResult selectPostByPostClass(@PathVariable String postClass){
        return JsonResult.ok(trainingService.selectPostByPostClass(postClass));
    }


    /**
     * 根据id修改晋升计划中的考核结果(未通过)
     */
    @PostMapping("/updateNoPromotion/{id}")
    public JsonResult updatePromotionStateNoById(@PathVariable String id){
        trainingService.updatePromotionStateNoById(id);
        return JsonResult.ok("操作成功!");
    }


    /** 报废
     * 根据日期对晋升计划结果 =>   等待复判
     */
    @GetMapping("/selectPromotion/{date}")
    public JsonResult selectPromotionByDate(@PathVariable String date){
        return JsonResult.ok(trainingService.selectPromotionByDate(date));
    }

    /**
     * 导入绩效考核表
     */
    @PostMapping("/insertAssess")
    public JsonResult insertAssess(@RequestBody List<InsertAssessDTO> list){
        trainingService.insertAssess(list);
        return JsonResult.ok("导入完成!");
    }

    /**
     * 查询绩效考核列表
     */
    @GetMapping("/selectAssessList")
    public JsonResult selectSelectList(
            @RequestParam(required = false, defaultValue = Common.DEFAULT_PAGE) Integer page,
            @RequestParam(required = false, defaultValue = Common.DEFAULT_PAGE_SIZE) Integer pageSize){
        return JsonResult.ok(trainingService.selectSelectList(page,pageSize));
    }

    /**
     * 根据查询内容的结果绩效考核列表
     */
    @PostMapping("/select/do/foreign/assess/picture")
    public JsonResult selectDoAssessPicture(@RequestBody List<SelectDoForeignPictureDTO> list){
        return JsonResult.ok(trainingService.selectDoAssessPicture(list));
    }

    /**
     * 添加考核记录
     */
    @PostMapping("/addAssess")
    public JsonResult addAssess(InsertAssessDTO dto){
        trainingService.addAssess(dto);
        return JsonResult.ok("添加成功!");
    }

    /**
     * 根据人查询考核记录中总核对, 如总扣分等等 一段提示
     */
    @GetMapping("/select/count/assess/{name}")
    public JsonResult selectCountAssessByName(@PathVariable String name){
        return JsonResult.ok(trainingService.selectCountAssessByName(name));
    }

    /**
     * 根据人查询总培训课程的进度,  一段提示
     */
    @GetMapping("/select/count/class/{name}")
    public JsonResult selectCountClassByName(@PathVariable String name){
        return JsonResult.ok(trainingService.selectCountClassByName(name));
    }

    /**
     * 根据人查询培训的合格率,  一段提示
     */
    @GetMapping("/select/count/training/{name}")
    public JsonResult selectCountTrainingByName(@PathVariable String name){
        return JsonResult.ok(trainingService.selectCountTrainingByName(name));
    }

    /**
     * 根据人查询培训的合格率,  一段提示
     */
    @GetMapping("/select/count/training/workshop")
    public JsonResult selectCountTrainingByWorkshop(){
        return JsonResult.ok(trainingService.selectCountTrainingByWorkshop());
    }

    /**
     * 获取人员架构层级信息
     */
    @GetMapping("/getSchema")
    public JsonResult getSchema(){
        return JsonResult.ok(trainingService.getSchema());
    }

    /**
     * 根据id删除考试记录
     */
    @PostMapping("/delete/test/record/{id}")
    public JsonResult deleteTestRecordById(@PathVariable String id){
        trainingService.deleteTestRecordById(id);
        return JsonResult.ok("删除成功!");
    }

    /**
     * 根据id删除培训记录
     */
    @PostMapping("/delete/study/record/{id}")
    public JsonResult deleteStudyRecordById(@PathVariable String id){
        trainingService.deleteStudyRecordById(id);
        return JsonResult.ok("删除成功!");
    }

    /**
     * 根据制浆车间获取车间的人员名字
     */
    @GetMapping("/select/name/{workshop}")
    public JsonResult selectNameByWorkshop(@PathVariable String workshop){
        return JsonResult.ok(trainingService.selectNameByWorkshop(workshop));
    }

    /**
     * 获取制浆分类车间信息
     */
    @GetMapping("/select/pulping/workshop")
    public JsonResult selectPulpingWorkshop(){
        return JsonResult.ok(trainingService.selectPulpingWorkshop());
    }


    /**
     * 获取制浆具体车间信息
     */
    @GetMapping("/select/pulping/workshop/common")
    public JsonResult selectPulpingWorkshopCommon(){
        return JsonResult.ok(trainingService.selectPulpingWorkshopCommon());
    }

    /**
     * 根据id删除考核记录
     */
    @PostMapping("/delete/performance/assess/{id}")
    public JsonResult deletePerformanceById(@PathVariable String id){
        trainingService.deletePerformanceById(id);
        return JsonResult.ok("删除成功!");
    }

}

